<?php
namespace app\cms\controller;

use app\common\controller\Front;

class Index extends Front
{
    private $items = [];
    
    public function _initialize()
    {
        parent::_initialize();
    }
    
    public function index()
    {
        $info = [];
        $info['pagePath']       = DcUrl('cms/index/index',['pageNumber'=>'[PAGE]']);
        $info['pageSize']       = intval(config('cms.limit_index'));
        $info['pageNumber']     = $this->site['page'];
        $info['seoTitle']       = cmsSeo(config('cms.index_title'),$this->site['page']);
        $info['seoKeywords']    = cmsSeo(config('cms.index_keywords'),$this->site['page']);
        $info['seoDescription'] = cmsSeo(config('cms.index_description'),$this->site['page']);
        //数据列表按置顶的排序
        if($info['pageSize']){
            $this->items = cmsSelect([
                'cache'    => true,
                'status'   => 'normal',
                'action'   => 'index',
                'controll' => 'detail',
                'module'   => 'cms',
                'start'    => $this->query['pageStart'],
                'field'    => config('cms.field_select'),
                'simple'   => config('cms.total_index'),
                'sort'     => config('cms.sort_index'),
                'order'    => 'desc',
                'paginate'=> [
                    'list_rows' => $info['pageSize'],
                    'page'      => $info['pageNumber'],
                    'path'      => $info['pagePath'],
                ]
            ]);
            if(config('cms.total_index') && config('cms.page_start')){
                $this->items['page_list'] = cmsPageList($this->items['next_item'][0]['info_id'],DcUrl('cms/index/index',['pageStart'=>'[PAGE]']));
            }
        }
        //变量赋值
        $this->assign($info);
        //数据列表
        $this->assign($this->items);
        //加载模板
        return $this->fetch();
    }
}